module.exports=()=>{
	/**
	 * 得到当前月份的最后一天
	 */
	Date.prototype.getCurrentMonthLastDate = function() {
		this.getMonthDay();
	};
	/**
	 * 返回Date年份中month的天数
	 * @param {Object} month 从1开始算
	 */
	Date.prototype.getMonthDay = function(month) {
		var me = this,
			m = month ? (month - 1) : me.getMonth(),
			day_array = [30, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
			y = me.getFullYear();
		((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) && (day_array[1] = 29); //润年2月29天
		return day_array[m];
	};
	/**
	 * 返回二位数当前月份的（01、02...12）
	 */
	Date.prototype.getFullMonth = function() {
		var m = this.getMonth() + 1;
		return m > 9 ? m : "0" + m;
	};
	
	/**
	 * 返回当前月份的二位数天数（01、02...31）
	 */
	Date.prototype.getFullDate = function() {
		var d = this.getDate();
		return d > 9 ? d : "0" + d;
	};
	Date.prototype.getFullHours = function() {
		var d = this.getHours();
		return d > 9 ? d : "0" + d;
	};
	Date.prototype.getFullMinutes = function() {
		var d = this.getMinutes();
		return d > 9 ? d : "0" + d;
	};
	Date.prototype.getFullSeconds = function() {
		var d = this.getSeconds();
		return d > 9 ? d : "0" + d;
	};
	/**
	 * 格式化日期的输出形式
	 */
	Date.prototype.formatDateString = function(format) {
		var y = this.getFullYear(),
			m = this.getFullMonth(),
			d = this.getFullDate(),
			reback = "",
			concatDate = function(sign) {
				return y + sign + m + sign + d;
			};
		if (/^yyyy-mm$/i.test(format)) {
			reback = y+"-"+m;
		}else if (/^yyyy-mm-dd$/i.test(format)) {
			reback = concatDate("-");
		} else if (/^yyyy-mm-dd hh:MM$/i.test(format)) {
			reback = y + "-" + m + "-" + d + " " + this.getFullHours() + ":" + this.getFullMinutes();
		} else if (/^yyyy-mm-dd hh:MM:ss$/i.test(format)) {
			reback = y + "-" + m + "-" + d + " " + this.getFullHours() + ":" + this.getFullMinutes()+ ":" + this.getFullSeconds();
		} else if (/^yyyy.mm.dd$/i.test(format)) {
			reback = concatDate(".");
		} else if (/^yyyy年mm月dd日$/.test(format)) {
			reback = y + "年" + m + "月" + d + "日";
		} else {
			reback = concatDate("");
		}
		return reback;
	};
	
	Date.prototype.getWeekDay = function() {
		return "星期" + ["日", "一", "二", "三", "四", "五", "六"][this.getDay()];
	};
}